package vip.hntool.excel;

import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import org.apache.poi.ss.usermodel.PictureData;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.FileOutputStream;
import java.util.List;
import java.util.UUID;

/**
 * 读取excel里面的图片
 * @author admin
 */
public class ExcelReadImgUtil {

    public static void main(String[] args) throws Exception {
    ExcelReader reader = ExcelUtil.getReader("test.xlsx");
    Workbook workbook = reader.getWorkbook();
    List<? extends PictureData> pictures = workbook.getAllPictures();
    for (PictureData picture : pictures) {
        byte[] data = picture.getData();
        FileOutputStream out = new FileOutputStream(
                UUID.randomUUID() + ".jpg");
        out.write(data);
        out.close();
    }
    }

}
